<?php
namespace MyProject\EhrBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface,
    My\EhrBundle\Entity\Account;

class AccountFixtures implements FixtureInterface
{
    public function load($em)
    {
        $accounts   = array();
        $accounts[] = array( 'admin','123', 0, 'Administrator');
        $accounts[] = array( 'supervisi','123', 0, 'Supervisor');
        #$accounts[] = array( '23412243','123', 1, 'Employee');

        foreach ($accounts as $account )
        {
            self::createAccount($account, $em);
        }
        $em->flush();
    }
    public static function createAccount( $data, $em )
    {
        $account = new Account();
        $account->setLogin( $data[0] );
        $account->setPassword( md5( $data[1] . 'palang-merah-indonesia') );
        $account->setRef( $data[2] );
        $account->setAksesControl($data[3]);

        $em->persist($account);

        return $account;
    }
}
?>
